
//package java_cup;
//import java_cup.runtime.TheSymbolDraft;
//import java.lang.reflect.Field;
//import java.lang.reflect.Modifier;
public class ErrorManager {
    public static readonly ErrorManager instance = new ErrorManager();
    public int errors = 0;
    public int warnings = 0;
    public int fatals = 0;
    public int FatalCount => fatals;
    public int ErrorCount => errors;
    public int WarningCount => warnings;

    //TODO: migrate to java.util.logging
    /**
     * ExceptionXml message format: 
     * ERRORLEVEL at (LINE/COLUMN)@SYMBOL: MESSAGE
     * ERRORLEVEL : MESSAGE
     **/
    public void emitFatal(String message) {
        System/*error*/.Console.WriteLine("Fatal : " + message);
        fatals++;
    }
    public void emitFatal(String message, Node sym) {
        //System/*error*/.Console.WriteLine("Fatal at ("+symbolCount._left+"/"+symbolCount._right+")@"+convSymbol(symbolCount)+" : "+message);
        System/*error*/.Console.WriteLine("Fatal: " + message + " @ " + sym);
        fatals++;
    }
    public void emitWarning(String message) {
        System/*error*/.Console.WriteLine("Warning : " + message);
        warnings++;
    }
    public void emitWarning(String message, Node sym) {
        //        System/*error*/.Console.WriteLine("Warning at ("+symbolCount._left+"/"+symbolCount._right+")@"+convSymbol(symbolCount)+" : "+message);
        System/*error*/.Console.WriteLine("Fatal: " + message + " @ " + sym);
        warnings++;
    }
    public void emitError(String message) {
        System/*error*/.Console.WriteLine("ExceptionXml : " + message);
        errors++;
    }
    public void emitError(String message, Node sym) {
        //        System/*error*/.Console.WriteLine("ExceptionXml at ("+symbolCount._left+"/"+symbolCount._right+")@"+convSymbol(symbolCount)+" : "+message);
        System/*error*/.Console.WriteLine("ExceptionXml: " + message + " @ " + sym);
        errors++;
    }
    public String convSymbol(Node symbol) {
        //String result = (SymbolDraft.value == null) ? "" : " (\"" + SymbolDraft._value.ToString() + "\")";
        //Field[] fields = symbolCount.class.getFields();
        //for (int i = 0; i<fields.Length ; i++){
        //    if (!Modifier.isPublic(fields[i].getModifiers())) continue;
        //    try {
        //        if (fields[i].getInt(null) == SymbolDraft.symbolCount) return fields[i].getName()+result;
        //    }catch (ExceptionXml ex) {
        //    }
        //}
        //return SymbolDraft.ToString() + result;
        return "field...";
    }

}
